//Made by kippieeej aka Bassoe
var chickenms = 0;
var on = 1;
var off = 0;
var activated = on;

function start() {
	chickenms = -1;
	action(1, 0, 0);
}

function action(mode, type, selection) {
	if (mode == -1) {
		cm.dispose();
	} else {
		if (mode == 0 && chickenms == 0) {
			cm.dispose();
			return;
		}
		if (mode == 1)
			chickenms++;
		else
			chickenms--;
if (activated == on) {
		if (chickenms == 0) {
			if (cm.itemQuantity(4001026) >= 50) {
				cm.sendOk("#fUI/UIWindow.img/QuestIcon/4/0#\r\nYou got 50 #i4001026#!\r\nI will give you some #fUI/UIWindow.img/QuestIcon/8/0#");
				cm.gainItem(4001026, -50);
				cm.gainExp(75000);
				cm.dispose();
			} else {
				cm.sendSimple("Hello #h #, Welcome to #rChickenMS!#k\r\nYou have this much Keys #B" + (cm.itemQuantity(4001026) * 2) + "#\r\nWhat do you want to do?\r\n#L1##bTrade 10k #fUI/UIWindow.img/QuestIcon/7/0# for 9k #fUI/UIWindow.img/QuestIcon/8/0#!#k#l\r\n\r\n#L2##bTrade 10k #fUI/UIWindow.img/QuestIcon/8/0# for 9k #fUI/UIWindow.img/QuestIcon/7/0#!#k#l\r\n\r\n#L3##bI want to choose how much Exp i get!#k#l\r\n#L4##eNothing really..#n#l");
			}
		} else if (chickenms == 1) {
			if (selection == 1) {
				if (cm.getMeso() >= 10000 ) {
					cm.gainMeso(-10000);				
					cm.gainExp(9000);
					cm.gainItem(4001026, 1); 
					cm.dispose();
				} else {
					cm.sendOk("You don't have enough #bMesos#k\r\nDon't scam me or I will use this on you! #s5001001#");
					cm.dispose();
				}								
			} else if (selection == 2) {
				if (cm.getExp() >= 10000 ) {
                                        cm.gainMeso(9000);				
					cm.gainExp(-10000);
					cm.gainItem(4001026, 1); 
					cm.dispose();
				} else {
					cm.sendOk("You don't have enough #bExp#k\r\nDon't scam me or I will use this on you! #s5001001#");
					cm.dispose();
				}
			} else if (selection == 3) {
				var prompt = "How much exp do you want?\r\n#rI'm fixed, there's no limit anymore!#k";
				cm.sendGetText(prompt);
			} else {
				cm.sendOk("Oh. i see... Well then, have fun in #rChickenMS!#k");
				cm.dispose();
			}
		} else if (chickenms == 2) {
			qty = cm.getText();
			cost = (qty * 2);
				cm.sendYesNo("Do you really want to pay " + cost + " mesos for " + qty + " Exp?");
		} else if (chickenms == 3) {
			if(cm.getChar().isGM() == 1) {
				cm.gainExp(qty);
				cm.dispose();
			} else {
				if (cm.getMeso() >= cost) {
					cm.gainMeso(-cost);
					cm.gainExp(qty);
					cm.dispose();
				} else {
					cm.sendOk("You don't have enough #bMesos#k\r\nDon't scam me or I will use this on you! #s5001001#");
					cm.dispose();
				}
			}
		} else {
			cm.dispose();
		}
	} else {
		cm.sendOk("Im not activated");
		cm.dispose();
		}
	}
}